using System;
using System.Collections.Generic;
using System.Text;
using SP.Parameter;

namespace SP.HwDeferredRS
{
    /// <summary>
    /// A simple base map feature
    /// </summary>
    public class PseudoSpecularFusion : AbstractFusion
    {
        public PseudoSpecularFusion()
        {
            AddParameter(
                new ScalarParameter("specularStrength")
                .SetS(2.0f)
                .SetDesc("[0.0 - 2.0], the larger the value, the stronger the specular effect")
                );
        }

        public override string Name
        {
            get { return "PseudoSpecular"; }
        }

        public override string Desc
        {
            get { return ""; }
        }

        public override Stage Stage
        {
            get { return Stage.Relfection; }
        }

        public override int UVChannelCount
        {
            get { return 0; }
        }

        public override void Code(StringBuilder b, string platform)
        {
            AddLine(b, "float ndotv = saturate(dot(pipeline.Normal, -pipeline.ViewDir));");
            AddLine(b, "pipeline.Reflection += pipeline.Illumination * pow(ndotv, 16.0) * specularStrength;");
        }
    }
}
